import { BasicColumn, FormSchema } from "/@/components/Table"
import { rules } from "/@/utils/helper/validator"
import { render } from "/@/utils/common/renderUtils"
import { DescItem } from "/@/components/Description/index"
export const columns: BasicColumn[] = [
  {
    title: "转账金额",
    width: 100,
    fixed: "left",
    dataIndex: "amount",
    customRender: ({ text }) => {
      return text + "元"
    },
  },
  {
    title: "商户名称",
    width: 180,
    dataIndex: "mchName",
  },
  {
    title: "订单号",
    width: 210,
    dataIndex: "orderNo",
    slots: { customRender: "orderNo" },
  },
  {
    title: "收款账号",
    width: 210,
    dataIndex: "accountNo",
  },
  {
    title: "收款人姓名",
    width: 180,
    dataIndex: "accountName",
  },
  {
    title: "转账备注",
    width: 210,
    dataIndex: "transferDesc",
  },
  {
    title: "状态",
    width: 100,
    dataIndex: "status",
    customRender: ({ text }) => {
      let color = "green"
      if (text == "0") color = "#ffbe76"
      if (text == "1") color = "#ffbe76"
      if (text == "2") color = "green"
      if (text == "3") color = "#ff7675"
      if (text == "4") color = "#ff7675"

      return render.renderTag(render.renderDict(text, "transfer_order_status"), color)
    },
  },

  {
    title: "创建时间",
    width: 160,
    dataIndex: "createdAt",
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "unionOrderNo",
    label: "订单号",
    component: "Input",
    componentProps: {
      placeholder: "支付/商户/渠道订单号",
    },
    // colProps: {span: 6},
  },
  {
    label: "订单状态",
    field: "status",
    component: "JDictSelectTag",
    componentProps: {
      dictType: "pay_order_status",
      placeholder: "请选择订单状态",
    },
    // colProps: {span: 6},
  },
  {
    label: "回调状态",
    field: "notifyStatus",
    component: "JDictSelectTag",
    componentProps: {
      dictType: "pay_notify_status",
      placeholder: "请选择回调状态",
    },
    // colProps: {span: 6},
  },
  {
    label: "商户号",
    field: "mchNo",
    component: "Input",
    // colProps: {span: 6},
  },
  {
    label: "应用ID",
    field: "appId",
    component: "Input",
    // colProps: {span: 6},
  },

  {
    field: "fieldTime",
    component: "RangePicker",
    label: "创建时间",
    componentProps: {
      valueType: "Date",
    },
    colProps: { span: 12 },
  },
]

export const formDetailSchema: DescItem[] = [
  {
    label: "商户类型",
    field: "mchType",
    span: 2,
    render: (curVal, data) => {
      let color = "green"
      if (curVal == "1") color = "#FFCC33"
      if (curVal == "2") color = "green"

      return render.renderTag(render.renderDict(curVal, "mch_type"), color)
    },
  },
  {
    field: "mchNo",
    label: "商户号",
    span: 2,
  },
  {
    field: "mchName",
    label: "商户名称",
    span: 2,
  },
  {
    field: "appId",
    label: "应用ID",
    span: 2,
  },
  {
    field: "isvNo",
    label: "服务商号",
    span: 2,
  },
  {
    field: "transferId",
    label: "转账订单号",
    span: 2,
  },
  {
    field: "mchOrderNo",
    label: "商户转账单号",
    span: 2,
  },
  {
    field: "channelOrderNo",
    label: "渠道订单号",
    span: 2,
  },
  {
    field: "amount",
    label: "金额",
    span: 2,
    render: (curVal, data) => {
      const color = "green"
      return render.renderTag(curVal, color)
    },
  },
  {
    field: "currency",
    label: "货币代码",
    span: 2,
  },
  {
    field: "accountNo",
    label: "收款账号",
    span: 2,
    render: (curVal, data) => {
      const color = "green"
      return render.renderTag(curVal, color)
    },
  },
  {
    field: "accountName",
    label: "收款人姓名",
    span: 2,
  },
  {
    field: "transferDesc",
    label: "转账备注",
    span: 2,
  },
  {
    field: "status",
    label: "订单状态",
    span: 2,
    render: (curVal, data) => {
      let color = "green"
      if (curVal == "0") color = "#ffbe76"
      if (curVal == "1") color = "#ffbe76"
      if (curVal == "2") color = "green"
      if (curVal == "3") color = "#ff7675"
      if (curVal == "4") color = "#ff7675"

      return render.renderTag(render.renderDict(curVal, "transfer_order_status"), color)
    },
  },
  {
    field: "successTime",
    label: "转账成功时间",
    span: 2,
  },

  {
    field: "createdAt",
    label: "创建时间",
    span: 2,
  },
  {
    field: "updatedAt",
    label: "更新时间",
    span: 12,
  },

  {
    field: "divider",
    label: "",
    render: (curVal, data) => {
      return render.renderDivider()
    },
    span: 12,
  },

  {
    field: "ifCode",
    label: "接口代码",
    span: 2,
  },

  {
    field: "entryType",
    label: "入职类型",
    span: 2,
  },

  {
    field: "clientIp",
    label: "客户端IP",
    span: 12,
  },

  {
    field: "notifyUrl",
    label: "异步通知地址",
    span: 12,
  },

  {
    field: "divider",
    label: "",
    render: (curVal, data) => {
      return render.renderDivider()
    },
    span: 12,
  },

  {
    field: "channelOrderNo",
    label: "渠道订单号",
    span: 2,
  },

  {
    field: "errCode",
    label: "渠道错误码",
    span: 2,
  },

  {
    field: "errMsg",
    label: "渠道错误描述",
    span: 12,
  },

  {
    field: "channelExtra",
    label: "渠道额外参数",
    span: 12,
    render: (curVal, data) => {
      return render.renderInputTextArea({
        value: curVal,
        autoSize: {
          minRows: 3,
          maxRows: 3,
        },
        readOnly: true,
      })
    },
  },

  {
    field: "divider",
    label: "",
    render: (curVal, data) => {
      return render.renderDivider()
    },
    span: 12,
  },

  {
    field: "extParam",
    label: "商户扩展参数",
    span: 12,
    render: (curVal, data) => {
      return render.renderInputTextArea({
        value: curVal,
        autoSize: {
          minRows: 3,
          maxRows: 3,
        },
        readOnly: true,
      })
    },
  },
]
